package com.shenma2009.controller;

import com.shenma2009.domain.ResultResponse;
import com.shenma2009.log.SmLog;
import com.shenma2009.vo.IdVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author 军哥
 * @version 1.0
 * @description: IndexController
 * @date 2023/6/7 9:20
 */

@RestController
@RequestMapping(value = "/index")
@Slf4j
public class IndexController {

    @PostMapping(value = "listRandSmLog/{id}")
    @SmLog(value = "test", level = "debug")
    public ResultResponse listRandSmLog(@PathVariable("id") Integer id) {
        log.info("id="+id);
        return ResultResponse.SUCCESS(id);
    }

    @PostMapping(value = "/insertSmLog")
    @SmLog(value = "insert", level = "info")
    public ResultResponse insertSmLog(@RequestBody IdVo idVo) {
        log.info("id="+idVo.getId());

        return ResultResponse.SUCCESS(idVo);
    }

    @PostMapping(value = "/throwError")
    @SmLog(value = "insert", level = "info")
    public ResultResponse throwError() {
        String msg = null;
        System.out.println(msg.length());

        return ResultResponse.SUCCESS();
    }

}
